package map;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;

public class GsonTest {

	private static final Gson GSON = new Gson();

	private static final Type MAP_LIST_TYPE = new TypeToken<List<Map<String, Object>>>() {}.getType();

	public static void main(String[] args) {
		List<Map<String, Object>> mapList = new ArrayList<>();
		Map<String, Object> map = new HashMap<>();
		map.put("name", "aaaaa");
		map.put("age", "11");
		mapList.add(map);
		map = new HashMap<>();
		map.put("name", "bbb");
		map.put("age", "22");
		mapList.add(map);
		
		String json = GSON.toJson(mapList, MAP_LIST_TYPE);
		System.out.println(json);

	}

}
